package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.java.entity.AccountInfo;
import com.java.service.AccountService;
import com.java.util.resp.BaseRespone;
import com.java.util.resp.TableRespone;

@RestController
@RequestMapping("/admin")
public class AccountController {
	
	@Autowired private AccountService accountService;

	@PostMapping("/getAccounts")
	public TableRespone getAccounts(@RequestParam(required = false, defaultValue = "0") int page,
			@RequestParam(required = false, defaultValue = "0") int size) {
		return accountService.getAccountList(page, size);
	}

	@PostMapping("/updateAccountRole")
	public BaseRespone updateAccountRole(String accountId) {
		return accountService.updateRole(accountId);
	}

	@PostMapping("/saveAccountInfo")
	public BaseRespone saveAccountInfo(@RequestBody AccountInfo info) {
		return accountService.updateUser(info);
	}
}
